@extends('front.layout')
@section('title','首页')
@section('content')
    <div class="index_top clearfix">
        <div class="index_left">
            <div class="index_left_bg"><img src="/assets/images/last_time_bg.jpg"/></div>
            <div class="index_left_body">
            @if($cnt>0)
                <!-- 后面获取时间后判断是未开始还是进行中-->
                    <?php
                    $start = \Illuminate\Support\Carbon::parse($oVideo->start_at);//取开始时间
                    $now = \Illuminate\Support\Carbon::now();
                    $end = \Illuminate\Support\Carbon::parse($oVideo->end_at);//取结束时间
                    ?>
                    @if($now < $start)
                        <div class="before">
                            <div class="last_time">
                                <span class="time1"></span>
                                <span class="time2"></span>
                                <span class="time3"></span>
                                <span class="time4"></span>
                            </div>
                            <a class="class_href" href="    #"></a>
                        </div>


                    @elseif($now > $end)

                    <!--会议结束-->
                        <div class="end_title">会议已结束</div>

                    @else
                    <!--会议进行中-->
                        <input type="hidden" id="url" value="{{$oVideo->website}}">
                        <div id="meeting" class="meeting" >
                            <a href="javascript:Pop_on_input()">
                                <img src="assets/images/online_classing.png" />
                            </a>
                        </div>
                    @endif
                @else
                <!--会议结束-->
                    <div class="end_title">已无直播</div>
                @endif

                <div class="left_share">
                    <span>分享到：</span>
                    <a href="javascript:void(0)" onclick="erweima()"><img src="/assets/images/icon_weixin.jpg"/></a>
                </div>

            </div>
        </div>
        <div class="index_right">
            <div class="title_box">专家介绍</div>
            <div class="index_right_list">

                @foreach($oVideo->experts as $v)


                    <div class="index_right_ship clearfix">
                        <div class="index_right_img">
                            <a href="/expert/info/{{$v->id}}"><img src="{{$v->thumb}}"/></a>
                        </div>
                        <div class="index_right_txt">
                            <p>专家: {{$v->name}}</p>
                            <p>职位: {{$v->position}}</p>
                            <p>医院: {{$v->hospital}}</p>
                            <p><a href="/expert/info/{{$v->id}}">详细</a></p>
                        </div>
                    </div>


                @endforeach
                <div class="index_right_more"><a href="/expert">more+</a></div>
            </div>
        </div>
    </div>
    <div class="review">
        <div class="title_box">精彩回顾</div>
        <div class="review_list">
            <div class="one_line clearfix">
                @foreach($oVideos as $v)
                    @foreach($v->experts as $expert)
                        <div class="review_ship " style="margin-right: 20px;">
                            <div class="review_ship_img">
                                <a href="/video/info/{{$v->id}}">
                                    <img width="270px" height="160px" src="{{$v->thumb}}" />
                                </a>
                            </div>
                            <div class="review_ship_txt">
                                <div class="review_ship_title break"><a href="/video/info/{{$v->id}}">{{$v->name}}</a></div>
                                <div class="review_ship_intro clearfix">
                                    <div class="review_ship_left">
                                        <p>主持： <a href="/expert/info/{{$expert->id}}">{{$expert->name}}</a></p>
                                        <p>日期：<span class="txt_999">{{$v->end_at}}</span></p>
                                    </div>
                                    <div class="review_ship_right">
                                        <a class="info_btn" href="/video/info/{{$v->id}}">查看详情</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    @endforeach
                @endforeach
            </div>
        </div>
    </div>
        @endsection
        <script>
            var starttime = new Date('{{$cnt>0?$oVideo->start_at:''}}');
            var endtime =new Date('{{$cnt>0?$oVideo->end_at:''}}');
            function count_down() {
                var nowtime = new Date();
                var time = starttime - nowtime;
                var time2=endtime-nowtime;
                if(time<=0 && time2<=0){
                    clearInterval(id);

                }
                var day = parseInt(time / 1000 / 60 / 60 / 24);
                var hour = parseInt(time / 1000 / 60 / 60 % 24);
                var minute = parseInt(time / 1000 / 60 % 60);
                var seconds = parseInt(time / 1000 % 60);

                var day1 = parseInt(time2 / 1000 / 60 / 60 / 24);
                var hour1 = parseInt(time2 / 1000 / 60 / 60 % 24);
                var minute1= parseInt(time2 / 1000 / 60 % 60);
                var seconds1 = parseInt(time2 / 1000 % 60);
                $('.time1').html(day);
                $('.time2').html(hour);
                $('.time3').html(minute);
                $('.time4').html(seconds);
                if(day==0&&hour==0&&minute==0&&seconds==0){
                    location.reload();
                }
                if(day1==0&&hour1==0&&minute1==0&&seconds1==0){
                    location.reload();
                }

            }
            var id = setInterval(count_down, 1000);
        </script>
        <div id="char_pop" class="chat_pop" style="display: none">
            <div id="char_close" class="chat_pop_top"><a onclick="Pop_close()" class="chat_pop_close"></a></div>
            <div class="chat_pop_body" >
                <img src="/assets/images/1.png" />
                <p>使用微信扫一扫，并将网页分享给好友</p>
            </div>
        </div>
        <!-- 姓名输入弹出框 -->
        <div id="name_pop" class="export_pop" style="display:none">
            <div class="export_pop_top">
                <span>提示</span>
                <a href="javascript:Pop_close()" class="export_pop_close"></a>
            </div>
            <div class="export_pop_body">
                <div>请输入您的姓名：</div>
                <div class="export_name_input"><input id="nick_name" type="text" /></div>
                <div class="export_name_submit"><input type="button" class="btn blue_btn" value="确定" onclick="join_meeting()"/></div>
            </div>
        </div>
        <!--微信引导页-->
        <div id="cover" class="phone_page" style="display: none">
            <div class="phone_top"><img src="assets/images/top.png" /></div>
            <div class="know"><a href="javascript:quit_pop()"><img src="assets/images/btn_bg.png" /></a></div>
        </div>
        <script>
            function erweima(){
                $.blockUI({
                    message:$("#char_pop"),
                    css:{border:'none'}
                });
            }
            function Pop_close(){
                $.unblockUI();
            }
            function refresh(){
                url=location.href;
                if(url.indexOf("#")==1){
                    url+="#";
                    self.location.replace(url);
                }
            }

            function Pop_on_input()//阻止用户界面，显示弹出窗口
            {
                $.blockUI({
                    message: $("#name_pop"),
                    css:{border:'none' }
                });
            }
            function join_meeting()
            {
                var nick_name=$("#nick_name").val();

                var url=$("#url").val();
                if(nick_name=="")
                {
                    alert("666");
                    return;
                }

                url=url+"?nickName="+nick_name;
                window.open(url);
            }


            function Pop_close()
            {
                $.unblockUI();
            }

            function quit_pop()
            {
                $("#cover").hide();
            }











</script>



